export interface ClineRawMessage {
  type: 'say' | 'ask';
  text: string;
  ts?: number;
  say?: string;
  ask?: string;
}

export type MessageContentType = 'text' | 'thinking' | 'command' | 'output' | 'api_debug';

export interface MessageContent {
  type: MessageContentType;
  text: string;
  language?: string;
  metadata?: Record<string, any>;
}

export const ClineMessageParser = {
  parseRawMessage(raw: ClineRawMessage): MessageContent | null {
    const { type, text, say, ask } = raw;
    if (say === 'checkpoint_created') return null;
    if (type === 'say' && say === 'text') return { type: 'text', text };
    if (type === 'say' && say === 'command') return { type: 'command', text, language: 'bash' };
    if (type === 'ask' && ask === 'command_output') return { type: 'output', text };
    return { type: 'text', text };
  }
};

